package com.example.logindemo;

import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;

import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.text.Editable;
import android.view.View;
import android.widget.EditText;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }

    public void click(View view) {
        EditText username = findViewById(R.id.username);
        String s = username.getText().toString();
        EditText pwd = findViewById(R.id.pwd);
        String p = pwd.getText().toString();
        if(s.equals("kuquan")&&p.equals("kuquan")) {
            AlertDialog dialog2 =new AlertDialog.Builder(this).setTitle("信息提示框")
                    .setMessage("登录成功")
                    .setPositiveButton("确定", new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                        }
                    })
                    .setIcon(R.mipmap.icon)
                    .create();
            dialog2.show();
        }else{
            AlertDialog dialog2 =new AlertDialog.Builder(this).setTitle("信息提示框")
                    .setMessage("账号或密码错误")
                    .setPositiveButton("确定", new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                        }
                    })
                    .setIcon(R.mipmap.icon)
                    .create();
            dialog2.show();
        }
    }

    public void click6(View view) {
        Intent intent=new Intent();
        intent.setClass(this, register.class);
        startActivity(intent);
    }

}